package dao.proxy.comm;

import java.util.List;

import dao.comm.ITitleDAO;
import dao.impl.comm.TitleDAOImpl;
import dbc.comm.DatabaseConnection;
import vo.comm.Title;

public class TitleDAOProxy implements ITitleDAO{
	private DatabaseConnection dbc=null;
	private ITitleDAO dao=null;
	public TitleDAOProxy() throws Exception{
		this.dbc=new DatabaseConnection();
		this.dao=new TitleDAOImpl(this.dbc.getConnection());
	}
	public boolean doCreate(Title title) throws Exception{
		boolean flag=false;
		if(this.dao.findByName(title.getTitlename())==null){
			flag=this.dao.doCreate(title);
		}
		this.dbc.close();
		return flag;
	}
	public boolean doDelete(Title title) throws Exception{
		boolean flag=false;
		flag=this.dao.doDelete(title);
		this.dbc.close();
		return flag;
	}
	public Title findByName(String titlename) throws Exception{
		Title title=null;
		title=this.dao.findByName(titlename);
		this.dbc.close();
		return title;
	}
	public List<Title> findAll(String keyWord) throws Exception{
		List<Title> all=null;
		all=this.dao.findAll(keyWord);
		this.dbc.close();
		return all;
	}
	public boolean doUpdate(Title title) throws Exception{
		boolean flag=false;
		flag=this.dao.doUpdate(title);
		this.dbc.close();
		return flag;
	}
}
